package com.bw.a2207a.view.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bw.a2207a.R
import com.bw.a2207a.bean.VideoInfoBean

/**
 *
 * @ClassName: MuAdapter
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/11/4 2:55 PM
 * @Version: 1.0
 */
class MuAdapter : RecyclerView.Adapter<MuAdapter.MyViewHoler>() {

    lateinit var mContext: Context
    val data = mutableListOf<VideoInfoBean>()
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHoler {
        if (viewType == 0) {
            return MyViewHoler(LayoutInflater.from(mContext).inflate(R.layout.item_video_0, null))
        } else if (viewType == 1) {
            return MyViewHoler(LayoutInflater.from(mContext).inflate(R.layout.item_video_1, null))
        }
        return MyViewHoler(LayoutInflater.from(mContext).inflate(R.layout.item_video_2, null))
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: MyViewHoler, position: Int) {


    }

    //处理多布局 类型
    override fun getItemViewType(position: Int): Int {
        //0:直播，1:普通，2:全屏
        return data.get(position).type
    }

    class MyViewHoler(itemView: View) : RecyclerView.ViewHolder(itemView) {
        private val imageView: ImageView
        private val tvTitle: TextView

        init {
            imageView = itemView.findViewById(R.id.iv)
            tvTitle = itemView.findViewById(R.id.tv_title)
        }
    }
}